<template>
	<view class="main-cont">
		<view class="content">
			<view class="box box-tb box-align-center box-pack-center">
				<button style="border-radius: 50%;overflow: hidden;width: 75px;height: 75px;padding: 0;"
					open-type="chooseAvatar" @chooseavatar="chooseAvatar" :ripple="true">
					<img :src="userinfo.icon" alt="" style="width: 100%;height: 100%;">
				</button>
				<text v-if="selecticon==false">点击获取头像</text>
				<!-- <view>{{userinfo.nickname}}</view> -->
				<input type="nickname" style="text-align: center;" v-model="userinfo.nickname">

				<view class="name">
					<span v-if="current==0">您正在申请成为管理员~</span>
					<span v-if="current==1">您正在申请成为老师~</span>
					<span v-if="current==2">您正在申请成为学生~</span>
				</view>
				<u-form :model="form" ref="uForm">
					<view class="box box-tb box-pack-center box-align-center mt66">
						<u-form-item prop="schoolname">
							<view class="list box box-align-center box-pack-start" @click="goSearchSchool()">
								<u-image src="@/static/class/icon_school.png" width="47rpx" height="33rpx"
									class="posa box box-align-center">
									<u-loading slot="loading"></u-loading>
								</u-image>
								<u-input v-model="form.schoolname" type="text" :disabled="true" :border="border"
									:custom-style="customStyles" placeholder="选择学校" @click="goSearchSchool()" />
								<u-image src="@/static/class/iocn_pulldown.png" width="32rpx" height="32rpx"
									class="posa box box-align-center">
									<u-loading slot="loading"></u-loading>
								</u-image>
							</view>
						</u-form-item>

						<u-form-item prop="xjname" v-if="showzyinfo">
							<view class="list box box-align-center box-pack-start" @click="goSearchxj()">
								<u-image src="@/static/class/icon_classgroup.png" width="35rpx" height="33rpx"
									class="posa box box-align-center">
									<u-loading slot="loading"></u-loading>
								</u-image>
								<u-input v-model="form.xjname" type="text" :disabled="true" :border="border"
									:custom-style="customStylecs" placeholder="选择学级" @click="goSearchxj()" />
								<u-image src="@/static/class/iocn_pulldown.png" width="32rpx" height="32rpx"
									class="posa box box-align-center">
									<u-loading slot="loading"></u-loading>
								</u-image>
							</view>
						</u-form-item>

						<u-form-item prop="zyname" v-if="showzyinfo">
							<view class="list box box-align-center box-pack-start" @click="goSearchzy()">
								<u-image src="@/static/class/icon_classgroup.png" width="35rpx" height="33rpx"
									class="posa box box-align-center">
									<u-loading slot="loading"></u-loading>
								</u-image>
								<u-input v-model="form.zyname" type="text" :disabled="true" :border="border"
									:custom-style="customStylecs" placeholder="选择专业" @click="goSearchzy()" />
								<u-image src="@/static/class/iocn_pulldown.png" width="32rpx" height="32rpx"
									class="posa box box-align-center">
									<u-loading slot="loading"></u-loading>
								</u-image>
							</view>
						</u-form-item>

						<u-form-item prop="bjname" v-if="showzyinfo">
							<view class="list box box-align-center box-pack-start" @click="goSearchClass()">
								<u-image src="@/static/class/icon_classgroup.png" width="35rpx" height="33rpx"
									class="posa box box-align-center">
									<u-loading slot="loading"></u-loading>
								</u-image>
								<u-input v-model="form.bjname" type="text" :disabled="true" :border="border"
									:custom-style="customStylecs" placeholder="选择班级" @click="goSearchClass()" />
								<u-image src="@/static/class/iocn_pulldown.png" width="32rpx" height="32rpx"
									class="posa box box-align-center">
									<u-loading slot="loading"></u-loading>
								</u-image>
							</view>
						</u-form-item>
						<u-form-item prop="phone">
							<view class="list box box-tb box-align-center box-pack-start">
								<view class="box box-align-center box-pack-start items">
									<u-image src="@/static/class/icon_phone.png" width="32rpx" height="36rpx"
										class="posa box box-align-center">
										<u-loading slot="loading"></u-loading>
									</u-image>
									<u-input v-model="form.phone" maxlength="11" type="text" :border="border"
										:custom-style="customStyles" placeholder="手机号" />
									<!-- <u-button size="medium" open-type="getPhoneNumber" :ripple="true"
										@getphonenumber="getPhoneNumber" :custom-style="btnOpen"
										class="u-hairline-border">自动获取</u-button> -->
								</view>
							</view>
						</u-form-item>
						<!-- <u-form-item prop="code">
							<view class="list box box-tb box-align-center box-pack-start">
								<view class="box box-align-center box-pack-start items">
									<u-image src="@/static/class/icon_user.png" width="32rpx" height="36rpx"
										class="posa box box-align-center">
										<u-loading slot="loading"></u-loading>
									</u-image>
									<u-input v-model="form.code" type="text" :border="border"
										:custom-style="customStyles" @input="inputauthcode" placeholder="验证码" />
									<view class="send-code" @click="getpostcode" v-if="able==false">{{sendcodetext}}
									</view>
									<view class="send-code" v-if="able == true">{{miao}}s</view>
								</view>
							</view>
						</u-form-item> -->
					</view>
					<u-button form-type="submit" :custom-style="loginbtnCustomStyle" :ripple="true"
						ripple-bg-color="#b0c1ff" :loading="btnloading==true" @click="save" :disabled="submitdisabled">
						登录</u-button>
					<view class="back" @click="back">
						返回
					</view>
				</u-form>
			</view>
		</view>
		<!-- 选择学校弹层 -->
		<!-- <u-popup v-model="schoolshowpop" mode="bottom" border-radius="14" height="65%"> -->
		<u-popup v-model="showpop" mode="bottom" border-radius="14" height="65%">
			<view class="main-cont box box-tb box-pack-start box-align-center">
				<view class="lists box box-align-center box-pack-start mt20">
					<!-- <u-input v-model="schoolsearchText" type="text" :border="border" :custom-style="customStyleInput"
						placeholder="搜索学校" /> -->
					<u-input v-model="searchText" type="text" :border="border" :custom-style="customStyleInput"
						@input="schoollist" placeholder="搜索学校" />
					<u-image src="@/static/class/icon_search.png" width="34rpx" height="34rpx" @click="schoollist">
						<u-loading slot="loading"></u-loading>
					</u-image>
				</view>

				<view class="padd20 school" v-if="page.list.length !=0">
					<view class="ite" v-for="(item,index) in page.list" :key="index" @click="doselectschool(item)">
						{{item.name}}
					</view>
				</view>
				<view class="mt20" v-else>
					<u-empty text="学校还未开通" mode="list"></u-empty>
					<view class="box box-tb call" @click="call">
						<view>
							体验请用游客登录
						</view>
						<view>
							试用请联系侯老师{{phone}}开通
						</view>
					</view>
				</view>
			</view>
		</u-popup>
		<!-- 选择学级弹层 -->
		<!-- <u-popup v-model="xjshowpop" mode="bottom" border-radius="14" height="65%"> -->
		<u-popup v-model="xjshowpop" mode="bottom" border-radius="14" height="65%">
			<view class="main-cont box box-tb box-pack-start box-align-center">
				<view class="lists box box-align-center box-pack-start mt20">
					<u-input v-model="searchTextxj" type="text" :border="border" :custom-style="customStyleInput"
						placeholder="搜索学级" />
					<u-image src="@/static/class/icon_search.png" width="34rpx" height="34rpx" @click="xjlist">
						<u-loading slot="loading"></u-loading>
					</u-image>
				</view>

				<view class="padd20 school" v-if="pagexj.length !=0">
					<view class="ite" v-for=" item in pagexj" :key="item" @click="doselectxj(item)">
						{{item+'级'}}
					</view>
				</view>
				<view style="height: 100%;" v-else>
					<u-empty text="暂无学级" mode="list"></u-empty>
				</view>
			</view>
		</u-popup>
		<!-- <u-popup v-model="zyshowpop" mode="bottom" border-radius="14" height="65%"> -->
		<u-popup v-model="zyshowpop" mode="bottom" border-radius="14" height="65%">
			<view class="main-cont box box-tb box-pack-start box-align-center">
				<view class="lists box box-align-center box-pack-start mt20">
					<u-input v-model="searchTextzy" type="text" :border="border" :custom-style="customStyleInput"
						@input="zylist" placeholder="搜索专业" />
					<u-image src="@/static/class/icon_search.png" width="34rpx" height="34rpx" @click="zylist">
						<u-loading slot="loading"></u-loading>
					</u-image>
				</view>

				<view class="padd20 school" v-if="pagezy.length !=0">
					<view class="ite" v-for="(item,index) in pagezy" :key="index" @click="doselectzy(item)">
						{{item.zymc}}
					</view>
				</view>
				<view v-else>
					<u-empty text="暂无专业" mode="list"></u-empty>
					<view class="box box-tb call" @click="call">
						<view>
							体验请用游客登录
						</view>
						<view>
							试用请联系侯老师{{phone}}开通
						</view>
					</view>
				</view>
			</view>
		</u-popup>

		<!-- 选择班级弹层 -->
		<!-- <u-popup v-model="bjshowpop" mode="bottom" border-radius="14" height="65%"> -->
		<u-popup v-model="classshowpop" mode="bottom" border-radius="14" height="65%">
			<view class="main-cont box box-tb box-pack-start box-align-center">
				<view class="lists box box-align-center box-pack-start mt20">
					<u-input v-model="searchTextbj" type="text" :border="border" :custom-style="customStyleInput"
						@input="bjlist" placeholder="搜索班级" />
					<u-image src="@/static/class/icon_search.png" width="34rpx" height="34rpx" @click="bjlist">
						<u-loading slot="loading"></u-loading>
					</u-image>
				</view>

				<view class="padd20 school" v-if="pagebj.length !=0">
					<view class="ite" :class="{active:item.trId ==null}" v-for="(item,index) in pagebj" :key="index"
						@click="doselectbj(item)">
						{{item.bjmc}}
					</view>
				</view>
				<view v-else>
					<u-empty text="暂无班级" mode="list"></u-empty>
					<view class="box box-tb call" @click="call">
						<view>
							体验请用游客登录
						</view>
						<view>
							试用请联系侯老师{{phone}}开通
						</view>
					</view>
				</view>
			</view>
		</u-popup>

		<u-toast ref="uToast" />
		<u-top-tips ref="uTips"></u-top-tips>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				nickname: '',
				phone: '13810289445',
				selecticon: false,
				submitdisabled: false,
				name: '',
				showzyinfo: false,
				sendcodetext: '获取验证码',
				miao: 60,
				able: false,
				showpop: false, //打开学校弹框
				zyshowpop: false, //打开专业弹框
				xjshowpop: false, //打开学级弹窗
				classshowpop: false, //打开班级弹窗
				form: {
					// schoolId: "",
					// schoolName: "",
					code: "",
					phone: "",
					schoolid: "",
					schoolname: "",
					zyid: "",
					zyname: "",
					xj: "",
					xjname: "",
					bjid: "",
					bjname: ""
					// selectedrole: ""
				},
				avatarstyle: {
					fontSize: '14px'
				},
				customStyle: {
					padding: "40rpx",
					color: "#fff"
				},
				userInfo: {
					width: "80px !important",
					height: "80px !important",
					border: "none"
				},
				customStyles: {
					padding: "0 60rpx 0 40rpx",
					color: "#fff"
				},
				customStylecs: {
					padding: "0 60rpx 0 52rpx",
					color: "#fff",
				},
				customStyleSfzh: {
					width: "190px",
					padding: "40rpx",
					color: "#fff"
				},
				placeholderStyle: {
					color: "#fff"
				},
				timer: null,
				loginbtnCustomStyle: {
					width: '560rpx',
					height: '86rpx',
					lineHeight: '86rpx',
					background: 'linearGradient(0deg, #DFE2F5, #FFFFFF)',
					boxShadow: '0px 14rpx 40rpx 0px #626BF1',
					borderRadius: '43rpx',
					fontSize: '34rpx',
					textAlign: 'center',
					color: '#858bec',
					fontWeight: '600',
					marginTop: '80rpx'
				},

				btnloading: false,
				authcode: '',
				btnOpen: {
					width: '165rpx',
					height: '74rpx',
					lineHeight: '74rpx',
					backGround: '#EDEFFF',
					borderRadius: '0 33rpx 33rpx 0',
					textAlign: 'center',
					color: '#626BF1',
					fontSize: '24rpx',
					padding: '0 20rpx'
				},
				searchText: '', //学校输入
				page: {
					pageNum: 1 //学校首页
				},
				searchTextzy: '', //专业输入
				pagezy: {},
				searchTextbj: '', //班级输入
				pagebj: {
					pageNum: 1 //班级首页
				},
				searchTextxj: '', //学级输入
				pagexj: {},
				rules: {
					phone: [{
							required: true,
							message: '请输入手机号',
							trigger: ['change', 'blur']
						},
						{
							// 自定义验证函数，见上说明
							validator: (rule, value, callback) => {
								// 上面有说，返回true表示校验通过，返回false表示不通过
								// this.$u.test.mobile()就是返回true或者false的
								return this.$u.test.mobile(value);
							},
							message: '手机号码不正确',
							// 触发器可以同时用blur和change
							trigger: ['change', 'blur'],
						}
					],
					// code: [{
					// 	required: true,
					// 	message: '请输入验证码',
					// 	trigger: ['change', 'blur'],
					// }],
					schoolname: [{
						required: true,
						message: '请选择学校',
						trigger: ['change', 'blur'],
					}],
					bjname: [{
						required: true,
						message: '请选择班级',
						trigger: ['change', 'blur'],
					}],
					xjname: [{
						required: true,
						message: '请选择学级',
						trigger: ['change', 'blur'],
					}],
					zyname: [{
						required: true,
						message: '请选择专业',
						trigger: ['change', 'blur'],
					}],
				},
				inputstyle: {
					color: '#3e4386',
					textAlign: 'center'
				},
				customStyleInput: {
					width: "560rpx",
					padding: "40rpx",
					color: "#000"
				},
				openid: '',
				unionid: '',
				icon: '',
				current: -1,
				userinfo: {
					icon: 'https://yhykt.oss-cn-beijing.aliyuncs.com/9CB0C5E9DCC1407CB63F90DF8BBAA886c3b3adb5a6b432cf48fe9541b466b96.png?Expires=4783045109&OSSAccessKeyId=LTAI4Fgsq7J3XQi7e2SRfzjJ&Signature=XSgHDNThJEpwPLOmu7%2Bvn%2Byz%2Fxk%3D',
					nickname: ''
				}, //微信用户信息对象
			}
		},
		onLoad: function(options) {
			this.current = parseInt(options.current);
			this.getPhone()
			if (this.current > 1) {
				this.showzyinfo = true;
			}
		},
		mounted() {
			this.getUnionidOnly();
			this.xjlist();
			this.createUser()
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
		methods: {
			getPhone() {
				let params = {
					searchText: '五育学院',
					pageNum: 1,
					pageSize: 12
				};
				this.$api.wypost({
					url: '/yschool/pagelist',
					method: 'post'
				}, params).then(res => {
					console.log(res)
					if (res.code == 0) {
						this.phone = res.page.list[0].tel
					}
				})
			},
			call() {
				wx.makePhoneCall({
					phoneNumber: this.phone, //仅为示例，并非真实的电话号码
					success: function() {
						console.log("拨打电话成功！")
					},
					fail: function() {
						console.log("拨打电话失败！")
					}
				})
			},
			//用户随机
			createUser() { //生成6位随机数
				var code = '';
				var codeLength = 6;
				var random = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
				for (var i = 0; i < codeLength; i++) {
					var index = Math.floor(Math.random() * 9);
					code += random[index];
				}
				return this.userinfo.nickname = '用户' + code;
			},
			back() {
				uni.navigateBack()
			},
			chooseAvatar(e) {
				console.log(e);
				this.userinfo.icon = e.detail.avatarUrl
				this.selecticon = true;
			},
			getUserProfile(e) {
				console.log(e);
				this.selecticon = true;
				return
				uni.getUserProfile({
					desc: 'Wexin',
					success: (res) => {
						console.log(res);
						this.userinfo.icon = res.userInfo.avatarUrl;
						this.userinfo.nickname = res.userInfo.nickName;
					}
				})
			},
			inputauthcode() {
				if (this.form.code.length == 6) {
					if (this.form.code != this.authcode) {
						this.$refs.uToast.show({
							title: '验证码错误',
							type: 'default'
						})
					} else if (this.miao <= 1) {
						this.$refs.uToast.show({
							title: '验证码过期',
							type: 'default'
						})
					}
				}
			},
			save() {
				this.$refs.uForm.validate(valid => {
					if (valid && this.userinfo.icon != '') {
						this.submitdisabled = true;
						uni.setStorageSync("unionid", this.unionid);
						uni.setStorageSync("mobile", this.form.phone);
						// //console.log(">>>"+uni.getStorageSync("unionid"))
						let params = {
							schoolId: this.form.schoolid,
							zydm: this.form.zyid,
							xj: parseInt(this.form.xj),
							classid: this.form.bjid,
							nickName: this.userinfo.nickname,
							icon: this.userinfo.icon,
							openId: this.openid,
							unionId: this.unionid,
							schoolname: this.form.schoolname,
							mobile: this.form.phone
						}
						this.$api.post({
							url: '/regedit/addStudent',
							method: 'post'
						}, params).then(res => {
							//console.log(res)
							if (res.code == 0) {
								this.$refs.uToast.show({
									title: '提交成功！',
									type: 'success',
									duration: '2300'
								})
								uni.navigateTo({
									url: './result'
								})
							} else if (res.code == 12000) {
								this.$refs.uToast.show({
									title: '重复注册，手机号已经存在',
									type: 'warning',
									duration: '2300'
								})
							} else {
								this.$refs.uToast.show({
									title: '操作失败！',
									type: 'error',
									duration: '2300'
								})
							}
						})
					} else {
						if (this.form.code != this.authcode) {
							this.$refs.uToast.show({
								title: '验证码错误',
								type: 'default'
							})
						} else if (this.userinfo.icon == '') {
							this.$refs.uToast.show({
								title: '请获取头像',
								type: 'default',
							})
						}
					}
				});
			},
			submit(e) {
				wx.vibrateShort();
				this.$refs.uForm.validate(valid => {
					if (valid && this.userinfo.icon != '') {
						this.submitdisabled = true;
						uni.setStorageSync("unionid", this.unionid);
						uni.setStorageSync("mobile", this.form.phone);
						// //console.log(">>>"+uni.getStorageSync("unionid"))
						let params = {
							schoolid: this.form.schoolid,
							zydm: this.form.zyid,
							xj: parseInt(this.form.xj),
							classid: this.form.bjid,
							name: this.userinfo.nickname,
							icon: this.userinfo.icon,
							appletopenid: this.openid,
							unionid: this.unionid,
							schoolname: this.form.schoolname,
							reason: '',
							type: 9,
							mobile: this.form.phone
						}
						this.$api.post({
							url: '/regedit/save'
						}, params).then(res => {
							//console.log(res)
							if (res.code == 0 && this.form.code == this.authcode) {
								this.$refs.uToast.show({
									title: '提交成功！',
									type: 'success',
									duration: '2300'
								})
								uni.navigateTo({
									url: './result'
								})
								// uni.setStorageSync("regeditstatus", 0);
								// 	wx.requestSubscribeMessage({
								// 		tmplIds: ['j5qPL6llmOH5l0vuxpHDuGLjcokyurA1rPABDiCb70g'],
								// 		success(rs) {
								// 			if (JSON.stringify(rs).indexOf('accept') > 0) {
								// 				//console.log("同意")
								// 			} eslse {
								// 				//console.log("拒绝")
								// 			}
								// 			uni.navigateTo({
								// 				url: './result'
								// 			})
								// 		},
								// 		fail(rs) {
								// 			//console.log(rs)
								// 		},
								// 	})

							}
						})
					} else {
						if (this.form.code != this.authcode) {
							this.$refs.uToast.show({
								title: '验证码错误',
								type: 'default'
							})
						} else if (this.userinfo.icon == '') {
							this.$refs.uToast.show({
								title: '请获取头像',
								type: 'default',
							})
						}
					}
				});
			},
			getUnionidOnly() {
				wx.login({
					success: res => {
						this.$api.post({
							url: '/comm/getAppletUnionid'
						}, {
							code: res.code
						}).then(s => {
							//console.log(s)
							this.openid = s.openid;
							this.unionid = s.unionid;
							// this.icon = s.user.icon
						})
					}
				})
			},
			doselectschool(school) {
				this.form.schoolid = school.id;
				this.form.schoolname = school.name;
				//console.log('学校名字' + this.form.schoolname)
				//console.log("学校id" + this.form.schoolid)
				this.showpop = false;
				this.form.zyid = '';
				this.form.zyname = '';
			},
			doselectzy(zy) {
				this.form.zyid = zy.zydm;
				this.form.zyname = zy.zymc;
				this.zyshowpop = false
				this.form.bjid = ''
				this.form.bjname = ''
			},
			doselectbj(bj) {
				if (bj.trId != null) {
					this.form.bjid = bj.id;
					this.form.bjname = bj.bjmc;
					this.classshowpop = false;
				} else {
					uni.showToast({
						title: "暂无带班老师，无法选择当前班级",
						icon: 'none'
					})

				}

			},
			bjlist() {
				let params = {
					schoolid: this.form.schoolid,
					searchText: this.searchTextbj,
					zydm: this.form.zyid,
					// pageNum: this.pagebj.pageNum,
					xj: this.form.xj
				}
				this.$api.post({
					url: '/dclass/bjlist'
				}, params).then(res => {
					//console.log(res)
					if (res.code == 0) {
						this.pagebj = res.list;
					}
				})
			},
			goSearchClass() {
				this.bjlist();
				this.classshowpop = true;
			},
			doselectxj(xj) {
				wx.vibrateShort();
				this.form.xjname = xj + '级';
				this.form.xj = xj;
				this.xjshowpop = false
			},
			xjlist() {
				this.$api.post({
					url: '/comm/getXj'
				}).then(res => {
					if (res.code == 0) {
						this.pagexj = res.list;
						if (this.form.xj == '') {
							this.form.xjname = this.pagexj[0] + '级';
							this.form.xj = this.pagexj[0];
						}
						//console.log(this.form.xjname, this.form.xj)
					}
				})
			},
			goSearchxj() {
				this.xjlist();
				this.xjshowpop = true;
				this.form.bjname = ''
				this.form.bjid = null
			},
			schoollist() {
				let params = {
					searchText: this.searchText,
					pageNum: this.page.pageNum,
					pageSize: 100
				}
				this.$api.post({
					url: '/yschool/pageSchoollist'
				}, params).then(res => {
					if (res.code == 0) {
						this.page = res.list;
					}
				})
			},
			zylist() {
				let params = {
					schoolid: this.form.schoolid,
					searchtext: this.searchTextzy
				}
				this.$api.post({
					url: '/dzy/list'
				}, params).then(res => {
					if (res.code == 0) {
						this.pagezy = res.list;
					}
					//console.log(this.pagezy)
				})
			},
			goSearchSchool() {
				this.schoollist();
				this.showpop = true;
			},
			goSearchzy() {
				this.zylist();
				this.zyshowpop = true
			},
			//获取手机号
			getPhoneNumber(e) {
				wx.vibrateShort();
				uni.login({
					provider: 'weixin',
					success: (res) => {
						let opts = {
							url: '/comm/getPhoneFromApplet',
							method: 'post'
						};
						let param = {
							encryptedData: e.detail.encryptedData,
							iv: e.detail.iv,
							code: res.code
						};
						this.$api.post(opts, param).then(resp => {
							//console.log(resp);
							this.form.phone = resp.phoneNumber;
							uni.setStorageSync('phone', this.form.phone)
						})
					}
				})
			},
			//验证码
			createCode() { //生成6位随机数
				var code = '';
				var codeLength = 6;
				var random = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
				for (var i = 0; i < codeLength; i++) {
					var index = Math.floor(Math.random() * 9);
					code += random[index];
				}
				return code;
			},
			//发送验证码
			getpostcode() {
				var myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
				if (this.form.phone.length == 0) {
					this.$refs.uToast.show({
						title: '请获取手机号',
						type: 'default',
					})
					return;
				}
				if (!myreg.test(this.form.phone) || this.form.phone.length !== 11) {
					this.$refs.uToast.show({
						title: '请输入正确的手机号格式',
						type: 'default'
					})
					return;
				}
				this.authcode = this.createCode()
				//console.log('验证码' + this.authcode)
				return
				this.$api.post({
					url: '/comm/sendMsg'
				}, {
					mobile: this.form.phone,
					authCode: this.authcode
				}).then(res => {
					//console.log('><>>' + res)
					if (res == "success") {
						this.$refs.uToast.show({
							title: '已发送成功',
							type: 'default',
						})
						this.getCode()
					} else {
						uni.showToast({
							title: '接口问题',
							icon: 'none'
						})
					}
				})
			},

			//倒计时
			getCode() {
				wx.vibrateShort();
				if (!this.timer) {
					// 通知验证码组件内部开始倒计时
					this.miao = 180;
					this.able = true;
					this.timer = setInterval(() => {
						if (this.miao > 0 && this.miao <= 180) {
							this.miao--;
							if (this.miao == 1) {
								this.authcode = "";
								this.sendcodetext = '发送'
							}
						} else {
							clearInterval(this.timer)
							this.able = false;
							this.timer = null
						}
					}, 1000);
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	.back {
		margin-top: 28rpx;
		width: 100%;
		font-size: 28rpx;
		color: #fff;
		text-align: center;
	}

	/deep/ .u-hairline-border::after {
		border: none !important;
	}

	/deep/.uline-1 .u-line-1 {
		font-size: 14px !important;
	}

	.send-code {
		width: 195rpx !important;
		height: 73rpx !important;
		line-height: 73rpx;
		background: #EDEFFF;
		border-radius: 0px 34rpx 34rpx 0px !important;
		text-align: center;
		color: #626BF1;
		font-size: 24rpx;
		padding: 0 20rpx;
	}

	// .icon {
	// 	width: 150rpx;
	// 	height: 150rpx;
	// 	border-radius: 75rpx;
	// }

	.mt66 {
		margin-top: 66rpx;
	}

	.mt150 {
		margin-top: 150rpx;
	}

	.main-cont {
		width: 100%;
		height: 100%;
	}

	.content {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		background: url(https://yh-sys.oss-cn-beijing.aliyuncs.com/6B9AF39796704A5CB130FC9C0CFB7A28icon_bg.png?Expires=4799124463&OSSAccessKeyId=LTAI4GL8SwAiLh3sSPXDS7z9&Signature=3z2ea85buEEsjoSlp5uw2FIOMoo%3D) no-repeat;
		background-size: 100%;
		color: #fff;
		background-color: #888bf3;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		/* color: #8f8f94; */
		color: $u-type-warning;
	}

	.login-tip {
		font-size: 36rpx;
	}

	//欢迎语句
	.name {
		display: flex;
		justify-content: space-between;
		height: 15px;
		line-height: 15px;
		font-size: 34rpx;
		font-weight: 500;
		color: #FFFFFF;
		margin-top: 5px;
	}

	span {
		display: block;
	}

	.login-btn {
		width: 560rpx;
		height: 86rpx;
		line-height: 86rpx;
		background: linear-gradient(0deg, #DFE2F5, #FFFFFF);
		box-shadow: 0px 14rpx 40rpx 0px #626BF1;
		border-radius: 43rpx;
		font-size: 34rpx;
		text-align: center;
		color: #626BF1;
		font-weight: 600;
	}

	/deep/ .u-input__input.data-v-fdbb9fe6 {
		padding-left: 17rpx;
	}

	/deep/ .u-form-item.data-v-5e7216f1 {
		padding: 10rpx 0;
	}

	.list {
		padding: 0 3rpx 0 30rpx;
		position: relative;
		width: 560rpx;
		height: 78rpx;
		background: #6E75F1;
		border: 2rpx solid #E9EAFF;
		border-radius: 39rpx;

		.items {
			width: 100%;
			height: 100%;
		}

		.tips {
			margin-top: 10rpx;
			width: 100%;
			margin-left: 20rpx;
			font-size: 20rpx;
			color: #D5D9F5;
		}

		&:nth-child(4) {
			padding-right: 5rpx;
		}
	}

	.lists {
		width: 710rpx;
		height: 86rpx;
		background: #F3F4FB;
		border-radius: 43rpx;
	}

	.school {
		width: 100%;
	}

	.ite {
		width: 100%;
		height: 95rpx;
		line-height: 95rpx;
		color: #2F3142;
		font-size: 30rpx;
		text-align: left;

		&.active {
			color: #ccc;
		}
	}


	/deep/.u-size-default.data-v-3bf2dba7 {
		font-size: 30rpx;
		width: 80px;
		height: 80px;
		line-height: 80rpx;
	}

	.call {
		width: 600rpx;
		color: #c0c4cc;
		text-align: center;
	}
</style>
